package com.xtc.netty.io.bio.http;

public interface MyServlet {

    String METHOD_GET = "GET";
    String METHOD_POST = "POST";

    /**
     * 处理客户端请求
     *
     * @param request
     * @param response
     */
    default void service(MyRequest request, MyResponse response) throws Exception {
        if (METHOD_GET.equalsIgnoreCase(request.getMethod())) {
            doGet(request, response);
        } else {
            doPost(request, response);
        }
    }

    /**
     * 处理post请求
     *
     * @param request
     * @param response
     */
    void doPost(MyRequest request, MyResponse response) throws Exception;

    /**
     * 处理get请求
     *
     * @param request
     * @param response
     */
    void doGet(MyRequest request, MyResponse response) throws Exception;
}
